package com.example.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    // 成功且无数据返回
    public static Result success(String msg){
        return new Result(Constants.CODE_200,msg,null);
    }

    // 成功且数据返回
    public static Result success(String msg,Object data){
        return new Result(Constants.CODE_200,msg,data);
    }

    // 失败
    public static Result error(Integer code,String msg){
        return new Result(Constants.CODE_0,msg,null);
    }
}
